﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace FormulariControlsIModelsDadesAlumnes
{
    public class DateToString : IValueConverter
    {
        //Convertir de la classe cap al formulari.
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            DateTime dt = (DateTime)value;

            
            return dt.ToString();
        }

        //Convertir del valor del formulari a la classe.
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            //System.Diagnostics.Debugger.Break();

            String s = (String)value;
            DateTime dt = new DateTime();
            try
            {
                dt = DateTime.Parse(s);
            }
            catch(Exception e)
            {

            }
            return dt;
        }
    }

}
